<?php
ob_start();
ob_start();
	include 'connect/connect.php';
	check_admin();
	include 'class/class.phieuthu.php';
?>
<head>
	<meta http-equiv="Content-Language" content="en-us">
	<link href="Calendar/CalendarControl.css"
		  rel="stylesheet" type="text/css">
	<script src="Calendar/CalendarControl.js"
			language="javascript"></script>
</head>


<form method="POST" action="#">
	<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
	<p>T&#7915;: <input type="text" name="dau" value="<?php echo $_POST['dau']; ?>" onfocus="showCalendarControl(this);" size="14">Đến ngày
	ngày: <input type="text" name="cuoi" onfocus="showCalendarControl(this);" value="<?php echo $_POST['cuoi']; ?>" size="15">
	<input type="submit" value="Ok" name="B1">&nbsp;&nbsp; (Viết dưới dạng ngày/tháng/năm)</p>
</form>

<?php

$phieuthu = new phieuthu;
	if ($_SESSION['user_admin']==1)
	{
	$result = mysql_query("SELECT * FROM tbl_thuphieu") or die(mysql_error()); 
	}
	else
	{
	$result = mysql_query("SELECT * FROM tbl_thuphieu WHERE id = ".$_SESSION['user_id']) or die(mysql_error());;
	}
  
	$list1 = explode("/",date('d/m/20y'));
		
$dau = $_POST['dau'];
$cuoi = $_POST['cuoi'];
	$dau = strtotime($dau);
	$cuoi = strtotime($cuoi);
 if ($dau != '' and $cuoi != '')
{
			echo "<table border='1' style='border-collapse: collapse'>";
			echo   '<td width="59" bgcolor="#D6E0D8">Mã phiếu</td>
			<td width="75" bgcolor="#D6E0D8">Ngày tạo</td>
			<td width="51" bgcolor="#D6E0D8">Tiền học phí</td>
			<td width="59" bgcolor="#D6E0D8">Tiền giảm thu</td>
			<td width="70" bgcolor="#D6E0D8">Tiền phụ thu</td>
			<td width="78" bgcolor="#D6E0D8">Tiền thực thu</td>
			<td width="98" bgcolor="#D6E0D8">Người tạo</td>
			<td width="87" bgcolor="#D6E0D8">Mã học viên</td>
			<td width="116" bgcolor="#D6E0D8">Họ và tên</td>
			<td bgcolor="#D6E0D8">Mã lớp</td>
			<td bgcolor="#D6E0D8">Trạng thái</td><td bgcolor="#D6E0D8">Khóa</td><td bgcolor="#D6E0D8">Giảng viên</td><td bgcolor="#D6E0D8">Hoa hồng</td><td bgcolor="#D6E0D8">Đính kèm</td><td bgcolor="#D6E0D8">Edit</td>';
    while ($row = mysql_fetch_array($result))
    {
		$ngaytao = strtotime($row['f_ngaytao']);
		if($ngaytao >= $dau && $ngaytao <= $cuoi) 
		{	
			  echo "<tr>";
			  echo "<td>" . $row['f_maphieu'] . "</td>";
			  echo "<td>" . $row['f_ngaytao'] . "</td>";
			  echo "<td>" .   number_format($row['f_tienhp']) . "</td>";
			  echo "<td>" .  number_format($row['f_tiengt']) . "</td>";
			  echo "<td>" . number_format( $row['f_tiencd']) . "</td>";			  
			  echo "<td>" .  number_format($row['f_thucthu']) . "</td>";
			  echo "<td>" . $row['f_nguoitao'] . "</td>";
			  echo "<td>" . $row['f_mahocvien'] . "</td>";
			  echo "<td>" . $row['f_hovaten'] . "</td>";
			  echo "<td>" . $row['f_lop'] . "</td>";			  
			  echo "<td>" .$phieuthu->trang_thai($row['f_trangthai']) . "</td>";echo "<td>" .$phieuthu-> khoa ($row['f_khoa']) . "</td>";echo "<td>" .$row['f_tengiangvien'] .  "</td>";echo "<td>" .$row['f_hoahong'] .  "</td>";echo "<td><a href='" .$row['file'] .  "'>Link</a></td>";echo "<td> <a href='edit.php?stt=".$row['f_maphieu'] ."'>E</a></td>";		
			  echo "</tr>";
		}
    }
	
echo "</table>";
}
?>